package com.gill.aop.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

//@Aspect
//@Order(1)
//@Component
public class Aspect2 {

//	@Pointcut(value = "execution(* com.gill.aop.service..*.*(..))")
//	public void embed(){}
//
//	/**
//	 * 指定以下通知在目标方法的执行时间
//	 */
//
//	@Before(value = "embed()")
//	public void before(JoinPoint joinPoint){
//		System.out.println(joinPoint+"【切面2：Before通知：开始调用】");
//	}
//
//	@After(value = "embed()")
//	public void after(JoinPoint joinPoint){
//		System.out.println(joinPoint+"【切面2：After通知：结束调用】");
//	}
//
//	@Around(value = "embed()")
//	public Object around(JoinPoint joinPoint) throws Throwable {
//		// 注意：Around通知分为三部分逻辑，上半逻辑、执行方法、下半逻辑，执行的时间不同
//		System.out.println("【切面2：Around通知的上半逻辑：在Before通知之前】");
//		Object result;
//		long start = System.currentTimeMillis();
//		// 执行目标方法
//		result = ((ProceedingJoinPoint)joinPoint).proceed();
//		long end = System.currentTimeMillis();
//		long pay_time = end - start;
//		System.out.println(joinPoint+"【切面2：Around通知的下半逻辑：在After通知之前】");
//		return result;
//	}
//
//	@AfterReturning(value = "embed()",returning = "result")
//	public void afterReturning(JoinPoint joinPoint,Object result){
//		System.out.println(joinPoint+"【切面2：AfterReturning通知】"+result);
//	}
//
//	@AfterThrowing(value = "embed()",throwing = "exception")
//	public void afterThrowing(JoinPoint joinPoint,Exception exception){
//		System.out.println(joinPoint+"【切面2：AfterThrowing通知】"+exception.getMessage());
//	}

}
